#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int Cmp_int(const void* p1, const void* p2)
{
	return *((int*)p1) - *((int*)p2);
}
void Swap(char* p1, char* p2, int size)
{
	for (int i = 0; i < size; i++)
	{
		char tmp = *p1;
		*p1 = *p2;
		*p2 = tmp;
		p1++;
		p2++;
	}
}
void My_qsort(void* base, size_t len, size_t size, int (*compar)(const void* p1, const void* p2))
{
	for (int i = 0; i < len - 1; i++)
	{
		for (int j = 0; j < len - 1 - i; j++)
		{
			if (compar(((char*)base) + j * size, ((char*)base) + (j + 1) * size) > 0)
			{
				Swap(((char*)base) + j * size, ((char*)base) + (j + 1) * size, size);
			}
		}
	}
}
void Print(int arr[], int len)
{
	for (int i = 0; i < len; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
}
int main()
{
	int arr[10] = { 2,1,5,3,7,8,6,4,0,9 };
	int len = sizeof(arr) / sizeof(arr[0]);
	Print(arr, len);
	My_qsort(arr, len, sizeof(arr[0]), Cmp_int);
	Print(arr, len);
}